--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Commit 6c5aec931c3ab8c8a7ee4fba19fa2c32adec3f4d
Parents : 39d4cbe
Author : Ivan <ivan@quad4.io>
Signature : Invalid signer <e46112d44649266d71fe2193e00a4710>, author is <ivan@quad4.io>
Date : 2026-07-09T08:24:19-05:00
refactor(Network Visualiser): optimize deduplication logic by replacing Set with Map for tracking seen node IDs, enhancing performance and clarity
Changes
1 files changed, 6 insertions(+), 4 deletions(-)
Diff
diff --git a/meshchatx/src/frontend/js/networkVisualiserPerf.js b/meshchatx/src/frontend/js/networkVisualiserPerf.js
index 0a607882..83b0774f 100644
--- a/meshchatx/src/frontend/js/networkVisualiserPerf.js
+++ b/meshchatx/src/frontend/js/networkVisualiserPerf.js
@@ -43,6 +43,7 @@ export function dedupeIconQueueEntries(queue) {
return [];
}
const byKey = new Map();
+ const seenByKey = new Map();
for (const item of queue) {
if (!item || typeof item !== "object" || !item.cacheKey || !item.nodeId) {
continue;
@@ -52,7 +53,6 @@ export function dedupeIconQueueEntries(queue) {
bucket = {
cacheKey: item.cacheKey,
nodeIds: [],
- _seen: new Set(),
iconName: item.iconName,
fg: item.fg,
bg: item.bg,
@@ -60,13 +60,15 @@ export function dedupeIconQueueEntries(queue) {
generation: item.generation,
};
byKey.set(item.cacheKey, bucket);
+ seenByKey.set(item.cacheKey, new Set());
}
- if (!bucket._seen.has(item.nodeId)) {
- bucket._seen.add(item.nodeId);
+ const seen = seenByKey.get(item.cacheKey);
+ if (!seen.has(item.nodeId)) {
+ seen.add(item.nodeId);
bucket.nodeIds.push(item.nodeId);
}
}
- return Array.from(byKey.values()).map(({ _seen, ...rest }) => rest);
+ return Array.from(byKey.values());
}
/**
──────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────